package Task28;

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JProgressBar;
import javax.swing.JLabel;

public class WaitWindow {

	private JFrame frmWaitWindow;

public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					WaitWindow window = new WaitWindow();
					window.frmWaitWindow.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	public WaitWindow() {
		initialize();
		
	}

	private void initialize() {
		frmWaitWindow = new JFrame();
		frmWaitWindow.setTitle("Wait window");
		frmWaitWindow.setBounds(100, 100, 236, 109);
		
		JProgressBar progressBar = new JProgressBar();
		
		JLabel lblSeparateThreadWork = new JLabel("Copy/move work in separate thread");
		GroupLayout groupLayout = new GroupLayout(frmWaitWindow.getContentPane());
		groupLayout.setHorizontalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addGroup(groupLayout.createSequentialGroup()
					.addContainerGap()
					.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
						.addComponent(progressBar, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 208, Short.MAX_VALUE)
						.addComponent(lblSeparateThreadWork))
					.addContainerGap())
		);
		groupLayout.setVerticalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addGroup(groupLayout.createSequentialGroup()
					.addContainerGap()
					.addComponent(progressBar, GroupLayout.DEFAULT_SIZE, 35, Short.MAX_VALUE)
					.addGap(18)
					.addComponent(lblSeparateThreadWork)
					.addGap(15))
		);
		frmWaitWindow.getContentPane().setLayout(groupLayout);
		progressBar.setIndeterminate(true);
	}

public void show(){
	frmWaitWindow.setVisible(true);
}

public void hide(){
	frmWaitWindow.setVisible(false);
}
}
